Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

export builder types to public API #220

Merged
merged 1 commit into from
Feb 28, 2023
Merged

export builder types to public API #220

merged 1 commit into from
Feb 28, 2023

Conversation

OmarTawfik
Copy link
Contributor

@OmarTawfik OmarTawfik commented Feb 26, 2023

cc @oli-obk .. Thanks for the awesome crate!

The builder types were not exported out of the crate, which means users cannot construct new messages.
This PR exposes the builder types, hidden behind the feature flag.

Any feedback is appreciated.

@oli-obk
Copy link
Owner

oli-obk commented Feb 27, 2023

Oh oops. Hmm... ideally that derive would produce something like MainType::builder() or similar so one can just use the type name instead of having to know about MainTypeBuilder... Do you happen to know if that is easily doable with some setting in the derive?

@OmarTawfik
Copy link
Contributor Author

@oli-obk not sure if Type::builder() is supported in derive_builder. Is this something in the docs? I believe TypeBuilder is the expected output.

After changes in this PR, users are able to do this:

    let message = DiagnosticBuilder::default()
        .message("something is wrong".to_string())
        .rendered(None)
        .level(DiagnosticLevel::Error)
        .code(Some(diagnostic_code))
        .spans(vec![diagnostic_span])
        .children(vec![])
        .build()?;

@oli-obk
Copy link
Owner

oli-obk commented Feb 28, 2023

I was just hoping that something more convenient would exist :)

Thanks for checking!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants